package component.hide
{
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.system.LoaderContext;
	
	public class Loader2 extends Loader
	{
		private var m_parent : Sprite
		
		public function Loader2(tParent:Sprite=null)
		{
			super();
			
			if(tParent)
			{
				m_parent = tParent;
			}
		}
		
		public function destory() : void
		{
			m_parent = null;
		}
		
		public  function load2(url:String, context:LoaderContext=null):void
		{
			var urlRequest : URLRequest = new URLRequest(url);
			
			super.load(urlRequest,context);
			
			if(m_parent)
			{
				this.addEventListener(Event.COMPLETE,onLoaderComplete);
			}
		}
		
		private function onLoaderComplete(evt : Event) : void
		{
			this.removeEventListener(Event.COMPLETE,onLoaderComplete);
			
			if(m_parent)
			{
				m_parent.addChild(this);
			}
		}
	}
}